package control;

import java.io.File;
import java.io.FileNotFoundException;
import divide.Division;

public class Controller {
	private String fileName;
	private String copyFile;
	
	public Controller(String fileName,String copyFile){
		this.fileName = fileName;
		this.copyFile = copyFile;
	}
	
	public void start() throws FileNotFoundException{
		File file = new File(fileName);
		long length = file.length();
		long buflength = (long) Math.ceil(length/5);
		
		Division d1 = new Division(fileName, copyFile, 0,buflength);
		Division d2 = new Division(fileName, copyFile, buflength,buflength*2);
		Division d3 = new Division(fileName, copyFile, buflength*2,buflength*3);
		Division d4 = new Division(fileName, copyFile, buflength*3,buflength*4);
		Division d5 = new Division(fileName, copyFile, buflength*4,buflength-buflength*4);
		
		new Thread(d1).start();
		new Thread(d2).start();
		new Thread(d3).start();
		new Thread(d4).start();
		new Thread(d5).start();
	}
	
	
	public static void main(String[] args) throws FileNotFoundException{
		new Controller("data.txt", "copy.txt").start();
	}
}
